<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2022/11/24
  Time: 21:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.cyy.bean.history" %>
<%@ taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<!DOCTYPE html>
<html>
<head>
    <title>购买记录</title>
</head>
<body>
<%
    Object message=request.getAttribute("message");
    if(message!=null&&!"".equals(message))
    {%>
    <script type="text/javascript">
        alert("<%=message%>");
    </script>
    <%}%>

    <rapid:override name="titleContent">
        <h2 align="center">我的购买记录</h2>
    </rapid:override>
    <rapid:override name="btContent">
        <div align="center">
            <button onclick="returnToIndex()">回到首页</button>
        </div>
    </rapid:override>
    <rapid:override name="mainContent">
        <div class="cart-page" align="center">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-2"></div>
                    <div class="col-md-8">
                        <div class="cart-page-inner">
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead class="thead-dark">
                                    <tr>
                                        <th>商品名字</th>
                                        <th>数目</th>
                                        <th>购买时间</th>
                                        <th>合计</th>
                                        <th>商品状态</th>
                                        <th>移除</th>
                                    </tr>
                                    </thead>
                                    <tbody class="align-middle">
                                    <%
                                        ArrayList<history> historys=(ArrayList<history>)request.getAttribute("history");
                                        if(historys!=null)
                                        {
                                            for (int i=0;i<historys.size();i++) {%>
                                    <tr>
                                        <td><%=historys.get(i).getProductName()%></td>
                                        <td><%=historys.get(i).getNum()%></td>
                                        <td><%=historys.get(i).getTime()%></td>
                                        <td><%=historys.get(i).getNum()*historys.get(i).getPrice()%></td>
                                        <%if(historys.get(i).getState()==0)
                                        {%>
                                        <td>待发货</td>
                                        <%}else{%>
                                        <td>已确认收货</td>
                                        <%}%>
                                        <td><a href="/deleteHistory?productName=<%=historys.get(i).getProductName()%>&time='<%=historys.get(i).getTime()%>'"><i class="fa fa-trash"></i></a></td>
                                    </tr>
                                    <%}}%>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2"></div>
                </div>
            </div>
        </div>
    </rapid:override>
    <%@ include file="customerProductIndex.jsp"%>
</body>
</html>
